﻿using Abp.Application.Services;
using AbpZeroTemplate.Web.Controllers;
using AbpZeroTemplate.Web.Swagger;
using Microsoft.AspNetCore.Antiforgery;
using Microsoft.AspNetCore.Mvc;

namespace AbpZeroTemplate.Api.Admin.Controllers
{
    /// <summary>获取验证的token
    /// </summary>
    [Area("Admin")]
    [Route("Admin/AntiForgery/[action]")]
    [ApiName("Admin")]
    [IgnoreAntiforgeryToken]
    [RemoteService]
    public class AntiForgeryController : AbpZeroTemplateControllerBase
    {
        private readonly IAntiforgery _antiforgery;
        /// <summary>ctor
        /// </summary>
        public AntiForgeryController(IAntiforgery antiforgery)
        {
            _antiforgery = antiforgery;
        }
        /// <summary>获取跨域Token
        /// </summary>
        [HttpGet]
        public void GetToken()
        {
            _antiforgery.SetCookieTokenAndHeader(HttpContext);
        }
    }
}
